const sizeClassMap = {
  small: 'size-small',
  medium: '',
  large: ''
};

Component({
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },

  properties: {
    title: {
      type: String,
      value: '暂无数据'
    },
    description: {
      type: String,
      value: '稍后再来看看，或点击重试'
    },
    image: {
      type: String,
      value: ''
    },
    size: {
      type: String,
      value: 'medium'
    },
    showAction: {
      type: Boolean,
      value: false
    },
    actionText: {
      type: String,
      value: ''
    }
  },

  data: {
    sizeClass: ''
  },

  lifetimes: {
    attached() {
      this.updateSizeClass();
    }
  },

  observers: {
    size() {
      this.updateSizeClass();
    }
  },

  methods: {
    updateSizeClass() {
      const sizeClass = sizeClassMap[this.properties.size] || '';
      this.setData({ sizeClass });
    },

    onAction() {
      this.triggerEvent('action');
    }
  }
});
